package com.java2nb.novel.pay.mapper;


import static com.java2nb.novel.pay.mapper.PayOrderDynamicSqlSupport.*;
import static com.java2nb.novel.pay.mapper.PayOrderDynamicSqlSupport.payOrderNo;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.java2nb.novel.pay.entity.PayOrder;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

import javax.annotation.Generated;
import java.util.List;

@Mapper
public interface PayOrderMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<PayOrder> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("PayOrderResult")
    PayOrder selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="PayOrderResult", value = {
            @Result(column="pay_order_no", property="payOrderNo", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="mch_no", property="mchNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="app_id", property="appId", jdbcType=JdbcType.VARCHAR),
            @Result(column="mch_order_no", property="mchOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="way_code", property="wayCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="amount", property="amount", jdbcType=JdbcType.INTEGER),
            @Result(column="currency", property="currency", jdbcType=JdbcType.VARCHAR),
            @Result(column="pay_status", property="payStatus", jdbcType=JdbcType.INTEGER),
            @Result(column="subject", property="subject", jdbcType=JdbcType.VARCHAR),
            @Result(column="body", property="body", jdbcType=JdbcType.VARCHAR),
            @Result(column="client_ip", property="clientIp", jdbcType=JdbcType.VARCHAR),
            @Result(column="notify_url", property="notifyUrl", jdbcType=JdbcType.VARCHAR),
            @Result(column="return_url", property="returnUrl", jdbcType=JdbcType.VARCHAR),
            @Result(column="expired_time", property="expiredTime", jdbcType=JdbcType.BIGINT),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="channel_trx_id", property="channelTrxId", jdbcType=JdbcType.VARCHAR),
            @Result(column="channel_user", property="channelUser", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_param", property="extParam", jdbcType=JdbcType.VARCHAR),
            @Result(column="close_time", property="closeTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="version", property="version", jdbcType=JdbcType.INTEGER),
            @Result(column="channel_extra", property="channelExtra", jdbcType=JdbcType.VARCHAR),
            @Result(column="pay_params", property="payParams", jdbcType=JdbcType.VARCHAR)
    })
    List<PayOrder> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(payOrder);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, payOrder);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(String payOrderNo_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, payOrder)
                .where(payOrderNo, isEqualTo(payOrderNo_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(PayOrder record) {
        return insert(SqlBuilder.insert(record)
                .into(payOrder)
                .map(payOrderNo).toProperty("payOrderNo")
                .map(mchNo).toProperty("mchNo")
                .map(appId).toProperty("appId")
                .map(mchOrderNo).toProperty("mchOrderNo")
                .map(wayCode).toProperty("wayCode")
                .map(amount).toProperty("amount")
                .map(currency).toProperty("currency")
                .map(orderState).toProperty("orderState")
                .map(subject).toProperty("subject")
                .map(body).toProperty("body")
                .map(clientIp).toProperty("clientIp")
                .map(notifyUrl).toProperty("notifyUrl")
                .map(returnUrl).toProperty("returnUrl")
                .map(expiredTime).toProperty("expiredTime")
                .map(createTime).toProperty("createTime")
                .map(payTime).toProperty("payTime")
                .map(channelTrxId).toProperty("channelTrxId")
                .map(channelUser).toProperty("channelUser")
                .map(extParam).toProperty("extParam")
                .map(closeTime).toProperty("closeTime")
                .map(updateTime).toProperty("updateTime")
                .map(version).toProperty("version")
                .map(channelExtra).toProperty("channelExtra")
                .map(payParams).toProperty("payParams")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(PayOrder record) {
        return insert(SqlBuilder.insert(record)
                .into(payOrder)
                .map(payOrderNo).toPropertyWhenPresent("payOrderNo", record::getPayOrderNo)
                .map(mchNo).toPropertyWhenPresent("mchNo", record::getMchNo)
                .map(appId).toPropertyWhenPresent("appId", record::getAppId)
                .map(mchOrderNo).toPropertyWhenPresent("mchOrderNo", record::getMchOrderNo)
                .map(wayCode).toPropertyWhenPresent("wayCode", record::getWayCode)
                .map(amount).toPropertyWhenPresent("amount", record::getAmount)
                .map(currency).toPropertyWhenPresent("currency", record::getCurrency)
                .map(orderState).toPropertyWhenPresent("orderState", record::getOrderState)
                .map(subject).toPropertyWhenPresent("subject", record::getSubject)
                .map(body).toPropertyWhenPresent("body", record::getBody)
                .map(clientIp).toPropertyWhenPresent("clientIp", record::getClientIp)
                .map(notifyUrl).toPropertyWhenPresent("notifyUrl", record::getNotifyUrl)
                .map(returnUrl).toPropertyWhenPresent("returnUrl", record::getReturnUrl)
                .map(expiredTime).toPropertyWhenPresent("expiredTime", record::getExpiredTime)
                .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
                .map(payTime).toPropertyWhenPresent("payTime", record::getPayTime)
                .map(channelTrxId).toPropertyWhenPresent("channelTrxId", record::getChannelTrxId)
                .map(channelUser).toPropertyWhenPresent("channelUser", record::getChannelUser)
                .map(extParam).toPropertyWhenPresent("extParam", record::getExtParam)
                .map(closeTime).toPropertyWhenPresent("closeTime", record::getCloseTime)
                .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
                .map(version).toPropertyWhenPresent("version", record::getVersion)
                .map(channelExtra).toPropertyWhenPresent("channelExtra", record::getChannelExtra)
                .map(payParams).toPropertyWhenPresent("payParams", record::getPayParams)
                .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }



    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default PayOrder selectByPrimaryKey(String payOrderNo_) {
        return SelectDSL.selectWithMapper(this::selectOne, payOrderNo, mchNo, appId, mchOrderNo, wayCode, amount, currency, orderState, subject, body, clientIp, notifyUrl, returnUrl, expiredTime, createTime, payTime, channelTrxId, channelUser, extParam, closeTime, updateTime, version, channelExtra, payParams)
                .from(payOrder)
                .where(payOrderNo, isEqualTo(payOrderNo_))
                .build()
                .execute();
    }
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>>.UpdateWhereBuilder updateByExample(PayOrder record) {
        return UpdateDSL.updateWithMapper(this::update, payOrder)
                .set(mchNo).equalTo(record::getMchNo)
                .set(appId).equalTo(record::getAppId)
                .set(mchOrderNo).equalTo(record::getMchOrderNo)
                .set(wayCode).equalTo(record::getWayCode)
                .set(amount).equalTo(record::getAmount)
                .set(currency).equalTo(record::getCurrency)
                .set(orderState).equalTo(record::getOrderState)
                .set(subject).equalTo(record::getSubject)
                .set(body).equalTo(record::getBody)
                .set(clientIp).equalTo(record::getClientIp)
                .set(notifyUrl).equalTo(record::getNotifyUrl)
                .set(returnUrl).equalTo(record::getReturnUrl)
                .set(expiredTime).equalTo(record::getExpiredTime)
                .set(createTime).equalTo(record::getCreateTime)
                .set(payTime).equalTo(record::getPayTime)
                .set(channelTrxId).equalTo(record::getChannelTrxId)
                .set(channelUser).equalTo(record::getChannelUser)
                .set(extParam).equalTo(record::getExtParam)
                .set(closeTime).equalTo(record::getCloseTime)
                .set(updateTime).equalTo(record::getUpdateTime)
                .set(version).equalTo(record::getVersion)
                .set(channelExtra).equalTo(record::getChannelExtra)
                .set(payParams).equalTo(record::getPayParams)
                .where(payOrderNo, isEqualTo(record::getPayOrderNo));
    }

    
}